package com.skyline.base.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.skyline.common.util.Constant;
import com.skyline.common.util.WebHelper;

/**
 * 验证模块的Controller
 * 
 * @author Jairus Chan
 * @version 0.1
 * */
//FIXME 建议移动到wo中
@Controller
public class CertCodeController {
	/**
	 * 验证用户所输入的验证码 （AJAX应用）
	 * 
	 * @param certcode
	 *            验证码
	 * @param httpServletRequest
	 * @return
	 */
	@RequestMapping("/certcode/verify/{certcode}")
	@ResponseBody
	public String verifyCertCode(@PathVariable String certcode) {
		String certCodeInSession = (String) WebHelper.getSessionAttribute(null, Constant.SESSION_CERT_CODE);
		if (certCodeInSession != null && certCodeInSession.equals(certcode)) {
			return "true";
		} else {
			return "false";
		}
	}
}
